package com.evil.Log;

/********************************************
 * 工程名：Web
 * 包名：com.evil.Log
 * 时间：16-9-23 下午7:27
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：生成用户每天答题情况列表日志
 ********************************************/
public class OverItemListLog
{
    private static final String HTML0 = "<!DOCTYPE html><html lang=\"en\"><head><meta" +
            " charset=\"UTF-8\"><title>";
    private static final String HTML1 = "</title><meta http-equiv=\"X-UA-Compatible\"" +
            " content=\"IE=edge\"><meta name=\"renderer\" content=\"webkit\">" +
            "<!--[if lte IE 7]><script src=\"/path/to/json2.js\"></script><![endif]-->" +
            "<!--[if lte IE 8]><script>document.createElement('ng-include');document" +
            ".createElement('ng-pluralize');document.createElement('ng-view');" +
            "// Optionally these for CSS document.createElement('ng:include');" +
            "document.createElement('ng:pluralize');document.createElement('ng:view');" +
            "</script><![endif]-->" +
            "<script src=\"http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js\">" +
            "</script><link href=\"http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/" +
            "bootstrap.min.css\" rel=\"stylesheet\"><style type=\"text/css\">*{margin:0;" +
            "padding:0}@-ms-viewport{width:980px}.main{width:980px;margin:auto}." +
            "table-center{width:100%;margin:auto;text-align:center;vertical-align:middle}." +
            "th-center{text-align:center}</style><script type=\"text/javascript\">" +
            "var app = angular.module('app',[]);app.controller('appController'" +
            ",function($scope,$http){$scope.sortIsAsc = true;$scope.overitemlist " +
            "= ";
    private static final String HTML2 = ";$scope.toggleSortByFlow = function(){$scope.sortIsAsc =!$scope" +
            ".sortIsAsc;$scope.overitemlist.sort(function(a,b){if($scope.sortIsAsc)" +
            "{if(a.sumFlow < b.sumFlow){return -1}if(a.sumFlow === b.sumFlow){retu" +
            "rn 0}return 1}if(a.sumFlow>b.sumFlow){return -1}if(a.sumFlow === b.su" +
            "mFlow){return 0}return 1})};$scope.toggleSortByTime = function(){$sco" +
            "pe.sortIsAsc =!$scope.sortIsAsc;$scope.overitemlist.sort(function(a,b)" +
            "{if($scope.sortIsAsc){if(a.overtime < b.overtime){return -1}if(a.overt" +
            "ime === b.overtime){return 0}return 1}if(a.overtime>b.overtime){return" +
            " -1}if(a.overtime === b.overtime){return 0}return 1})}});</script></hea" +
            "d><body><nav class=\"navbar navbar-default\" role=\"navigation\"><div c" +
            "lass=\"container-fluid\"><div class=\"navbar-header\"><a class=\"navbar" +
            "-brand\">";
    private static final String HTML3 = "</a></div></div></nav><div class=\"main\"><div class=\"pane" +
            "l panel-primary\"><div class=\"panel-heading\"><h3 class=\"panel-title\"" +
            ">基本信息</h3></div><div class=\"panel-body\"><table class=\"table table-hover" +
            " table-center\"><thead><tr><th class=\"th-center\">项目</th><th class=\"" +
            "th-center\">数量</th></tr></thead><tbody><tr><td>总用户量</td><td>";
    private static final String HTML4 = "</td> </tr><tr><td>日答题量</td><td>";
    private static final String HTML5 = "</td></tr><tr><td>日推送总流量</td><td>";
    private static final String HTML6 = "</td></tr></tbody></table></div></div><div class=\"panel panel-primary\">" +
            "<div class=\"panel-heading\"><h3 class=\"panel-title\">昨日答题信息</h3>" +
            "</div><div class=\"panel-body\" ng-app=\"app\" ng-controller=\"appController" +
            "\"><table class=\"table table-hover table-center\"><caption><span style=\"c" +
            "olor:red\">点击“获得流量”和“完成时间”可对列表进行排序</span></caption><thea" +
            "d><tr><th class=\"th-center\">序号</th><th class=\"th-center\">用户手机</t" +
            "h><th class=\"th-center\">题目序号</th><th class=\"th-center\">正确个数</th" +
            "><th class=\"th-center\">错误个数</th><th class=\"th-center\"><a ng-click=\"" +
            "toggleSortByFlow()\">获得流量</a></th><th class=\"th-center\"><a ng-click=\"" +
            "toggleSortByTime()\">完成时间</a></th></tr></thead><tbody><tr ng-repeat=\"x" +
            " in overitemlist\"><td>{{x.id}}</td><td>{{x.phone}}</td><td>{{x.itemId}}</t" +
            "d><td>{{x.yesNum}}</td><td>{{x.noNum}}</td><td>{{x.sumFlow}}</td><td>{{x.ov" +
            "ertime}}</td></tr></tbody></table></div></div></div></body></html>";

    private String title;/*标题*/
    private int userSum;/*总用户量*/
    private int overItemSum;/*日答题量*/
    private int flowSum;/*日推送总流量*/
    private String overItemListJson;/*用户答题详情JSON*/

    public OverItemListLog(String title, int userSum, int overItemSum, int flowSum, String overItemListJson)
    {
        this.title = title;
        this.userSum = userSum;
        this.overItemSum = overItemSum;
        this.flowSum = flowSum;
        this.overItemListJson = overItemListJson;
    }

    public String getHtml()
    {
        return HTML0 + title
                + HTML1 + overItemListJson
                + HTML2 + title
                + HTML3 + userSum
                + HTML4 + overItemSum
                + HTML5 + flowSum
                + HTML6;
    }
}
/*源码保留*/
/*<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>???</title>

<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">

<!--[if lte IE 7]>
<script src="/path/to/json2.js"></script>
<![endif]-->

<!--[if lte IE 8]>
<script>
        document.createElement('ng-include');
                document.createElement('ng-pluralize');
                document.createElement('ng-view');

                // Optionally these for CSS
                document.createElement('ng:include');
                document.createElement('ng:pluralize');
                document.createElement('ng:view');
</script>
<![endif]-->

<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
<link href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<!--
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap-theme.min.css"></script>
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        -->
<style type="text/css">
        * {
        margin: 0;
        padding: 0;
        }

@-ms-viewport {
        width: 980px;
        }

        .main {
        width: 980px;
        margin: auto;
        }

        .table-center {
        width: 100%;
        margin: auto;
        text-align: center;
        vertical-align: middle;
        }

        .th-center {
        text-align: center;
        }

</style>

<script type="text/javascript">
        var app = angular.module('app', []);
        app.controller('appController', function ($scope, $http) {

        $scope.sortIsAsc = true;

        //数据
        $scope.overitemlist = ? ? ?;

        $scope.toggleSortByFlow = function () {
        $scope.sortIsAsc = !$scope.sortIsAsc;
        $scope.overitemlist.sort(function (a, b) {
        if ($scope.sortIsAsc) {
        if (a.sumFlow < b.sumFlow) {
        return -1;
        }
        if (a.sumFlow === b.sumFlow) {
        return 0;
        }
        return 1;
        }
        if (a.sumFlow > b.sumFlow) {
        return -1;
        }
        if (a.sumFlow === b.sumFlow) {
        return 0;
        }
        return 1;
        });
        };

        $scope.toggleSortByTime = function () {
        $scope.sortIsAsc = !$scope.sortIsAsc;
        $scope.overitemlist.sort(function (a, b) {
        if ($scope.sortIsAsc) {
        if (a.overtime < b.overtime) {
        return -1;
        }
        if (a.overtime === b.overtime) {
        return 0;
        }
        return 1;
        }
        if (a.overtime > b.overtime) {
        return -1;
        }
        if (a.overtime === b.overtime) {
        return 0;
        }
        return 1;
        });
        };
        });
</script>

</head>
<body>

<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand">???</a>
</div>
</div>
</nav>

<div class="main">

<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">基本信息</h3>
</div>
<div class="panel-body">
<table class="table table-hover table-center">
<thead>
<tr>
<th class="th-center">项目</th>
<th class="th-center">数量</th>
</tr>
</thead>
<tbody>
<tr>
<td>总用户量</td>
<td>???</td>
</tr>
<tr>
<td>日答题量</td>
<td>???</td>
</tr>
<tr>
<td>日推送总流量</td>
<td>???</td>
</tr>
</tbody>
</table>
</div>
</div>

<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">昨日答题信息</h3>
</div>
<div class="panel-body" ng-app="app" ng-controller="appController">
<table class="table table-hover table-center">
<caption><span style="color:red">点击“获得流量”和“完成时间”可对列表进行排序</span></caption>
<thead>
<tr>
<th class="th-center">序号</th>
<th class="th-center">用户手机</th>
<th class="th-center">题目序号</th>
<th class="th-center">正确个数</th>
<th class="th-center">错误个数</th>
<th class="th-center"><a ng-click="toggleSortByFlow()">获得流量</a></th>
<th class="th-center"><a ng-click="toggleSortByTime()">完成时间</a></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="x in overitemlist">
<td>{{x.id}}</td>
<td>{{x.phone}}</td>
<td>{{x.itemId}}</td>
<td>{{x.yesNum}}</td>
<td>{{x.noNum}}</td>
<td>{{x.sumFlow}}</td>
<td>{{x.overtime}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>*/
